package 越短越合法

func numSubarrayProductLessThanK(nums []int, k int) int {
	sum := 1
	left := 0
	result := 0
	if k <= 1 {
		return 0
	}
	for right, num := range nums {
		sum *= num
		for sum >= k && left <= right {
			sum /= nums[left]
			left++
		}
		result += right - left + 1
	}
	return result
}
